#include <stdio.h>
#include <sys/types.h>  
#include <sys/socket.h>
#include <linux/in.h>  
#include <stdlib.h>
#include <sys/select.h>
#include <string.h>

int main(int argc, const char *argv[])
{
	int socketfd;
	char buf[32] = {1,2,3,4,5,67,8};

	socketfd = socket(AF_INET,SOCK_STREAM,0); //创建套接子
	if(socketfd == 0)
	{
		perror("err socket");
		return 1; 
	}

	struct sockaddr_in saddr;
	saddr.sin_family = AF_INET;
	saddr.sin_port = htons(8888);
	saddr.sin_addr.s_addr = inet_addr("127.0.0.1");  //绑定
	
	if( connect(socketfd,(struct sockaddr *)&saddr,sizeof(saddr)) <0 )
	{
		perror("connect err");
		return -1;
	}
	while(1)
	{
		scanf("%s",buf);
		send(socketfd,buf,10,0);
		recv(socketfd,buf,10,0);
	}
	close(socketfd);
	return 0;
}


